#ifndef __TICKET_DEVICE_H__
#define __TICKET_DEVICE_H__

#include "list.h"

#define ORIGIN_PLACE_SIZE       (20)
#define DESTINATION_SIZE        (20)
#define DEPARTURE_TIME          (7)
#define ARRIVAL_TIME            (7)
#define PRICE_SIZE              (3)
#define TICKET_NUM_SIZE         (3)
#define TRAIN_NUM_SIZE          (3)

struct ticket {
    char origin_place[ORIGIN_PLACE_SIZE];
    char destination[DESTINATION_SIZE];
    char train_number[TRAIN_NUM_SIZE];
    char departure_time[DEPARTURE_TIME];
    char arrival_time[ARRIVAL_TIME];
    char price[PRICE_SIZE];
    char ticket_number[TICKET_NUM_SIZE];
    struct list_head list;
};

extern int ticket_repeat_check(struct list_head *ticket_head, struct ticket *need_add_ticket);
extern int ticket_init(struct list_head *ticket_head, struct list_head *user_ticket_head);
extern int ticket_destroy(struct list_head *ticket_head, struct list_head *user_ticket_head);
extern int delete_user_ticket(char *train_number, struct list_head *current_user_ticket_head);
extern int add_user_ticket(struct list_head **current_user_ticket_head, struct ticket *buy_ticket);

#endif